<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head lang="en">
    <meta charset="UTF-8">
    <title>预约-科室名称</title>
    <base th:href="@{http://localhost:9090/}"/>
    <link th:href="@{/bs/css/bootstrap.css}" rel="stylesheet">
    <script th:src="@{/js/jquery-3.2.1.min.js}" type="text/javascript"></script>
    <script th:src="@{/bs/js/bootstrap.js}" type="text/javascript"></script>
    <style type="text/css">
        #body{
            width: 1200px;
            margin: 20px auto;
        }
        h1{
            width: 200px;
            margin: 0 auto;
            color: red;
        }
    </style>
    <script type="text/javascript">
        $(function (){
            $.ajax({
                url: "/getDepartment",
                type: "GET",
                data: "",
                dataType: "json",
                success:function(departmentList){
                    if (departmentList!=null){
                        show(departmentList);
                    }else {
                        alert("科室数据查询失败!")
                    }

                },
                error: function (departmentList){
                    alert("科室医生失败!")
                }
            });

        })

        function show(departmentList){
            var depStr = "";
            for (var i = 0; i < departmentList.length; i++) {
                depStr += '<div style="border: 1px solid #93DAFF; width:120px ; height:100px ; background-color: #93DAFF ; display: inline-block ; padding: 15px ; margin: 30px ">'
                    + '<p>' + departmentList[i].departmentName + '</p>'
                    + '<a id="id" onclick="aa(' + departmentList[i].departmentId + ')"  >点击选中</a>'
                    + '</div>';
            }

            $("#body").append(depStr);
        }
        function aa(id){
            var url = '/dmy/touserbooking?departmentId='+ id ;
            window.open(url,'_self')
        }


    </script>
</head>
<body>

<div id="body">
    <h1>请选择科室</h1>
</div>

</body>
</html>